<?php
function loadSkills() {
    $skills = array ();
    $rs = executeQuery("select id, name, skill_group from skills order by 1");
    while ($row = mysql_fetch_row($rs)) {
        $skill = new Skill($row);
        $skills[$skill->id] = $skill;
    }
    uasort($skills, "skillAlphaSort");
    return $skills;
}

function findSkill($name) {
    global $skills;
    if (strcasecmp("Claw", $name) ==0) {
        $name= "Claws";
    } else if (strcasecmp("Sidestep", $name) ==0) {
        $name= "Side Step";
    } else if (strcasecmp("Throw Team Mate", $name) ==0) {
        $name= "Throw Team-Mate";
    } else if (strcasecmp("Ball & Chain", $name) ==0) {
        $name= "Ball &amp; Chain";
    }   
    
    foreach ($skills as $skill) {
        if (0 == strcasecmp($skill->name, $name)) {
            return $skill;
        }
    }
    return false;
}

function skillAlphaSort($a, $b) {
	if (0 == strcmp("Loner", $a->name)) {
	    return -1;
	} 
	if (0 == strcmp("Loner", $b->name)){
	    return 1;
	} 
    return strcmp ($a->name, $b->name);
}

function compareSkill($a, $b) {
	return $a->id - $b->id;        
}
/*
 * Created on 12/10/2008
 *
 * To change the template for this generated file go to
 * Window - Preferences - PHPeclipse - PHP - Code Templates
 */
class Skill {
    var $id;
    var $name;
    var $group;

    function Skill($row) {
        $i = 0;
        $this->id = $row[$i++];
        $this->name = $row[$i++];
        $this->group = $row[$i++];
    }
}
?>
